// This file is part of OpenMeca, an easy software to do mechanical simulation.
//
// Author(s)    :  - Damien ANDRE  <openmeca@gmail.com>
//
// Copyright (C) 2012 Damien ANDRE
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef OpenMeca_Gui_UserItemDialog_hpp_1 //TODO: Why OpenMeca_Gui_UserItemDialog_hpp  
#define OpenMeca_Gui_UserItemDialog_hpp_1 //don't work ?

#include <QWidget>
#include <QAction>

#include "OpenMeca/ui/ui_UserItemDialog.h"
#include "OpenMeca/Gui/Dialog.hpp"
#include "OpenMeca/Core/SetOf.hpp"
namespace OpenMeca
{
  namespace Core
  {
    class UserItem;
  }

  namespace Gui
  {

    class Widget;

    class UserItemDialog : public Dialog, private Ui::UserItemDialog
    {
      Q_OBJECT
      
      public:
      void AddWidget(Widget&);
      void RemoveWidget(Widget&);
      virtual bool Check();
      


    public slots:
      void Preview();
      void Ok();
      void Cancel();

     protected:
      UserItemDialog();
      virtual ~UserItemDialog();
      QWidget& GetContainer(){return *container_;}
      virtual void showEvent (QShowEvent* event );
      virtual void Init() = 0;
      virtual Core::UserItem& GetCurrentUserItem() = 0;
      virtual bool IsCurrentUserItemStillExist() = 0;
      virtual void Reset();
      void SetAction(QAction& action);
      QAction& GetAction();
      void ActiveNewItemMode();
      void DisableNewItemMode();
      
    private:
      void ApplyChangement();
      void CancelChangement();
      void DisplayWarningUserItemNotExist();
      void ManageUserItemNotExist();

    private:
      Core::SetOf<Widget> widgets_;
      QAction* action_;
      bool newItemMode_;
    };

  }
}

#endif
